home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Info-Mac 4
/
Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso
/
Development
/
General
/
MM3Tp.sea Folder
/
Made by Marksman
/
Sources
/
mm
/
mmMD_My_Movable_Moda.p
< prev
next >
Wrap
Text File
|
1994-01-16
|
11KB
|
296 lines
Unit mmMD_My_Movable_Moda;
{ mmMD_My_Movable_Moda Handle this dialog }
{ Copyright © 1994 George R. Cossey }
{ File name: mmMD_My_Movable_Moda
Function: Handle this modeless dialog.
This dialog is called when:
History: 1/16/94 Original by George Cossey
}
{ ======================================================= }
{ ======================================================= }
interface
uses
Printing,Folders,Sound,mmCommonMM_Demo,CommonMM_Demo,
mmPA_My_Alert,
{}
mmD_My_Modal,
{}
UMy_Movable_Moda;
procedure Init_My_Movable_Moda;
procedure Moved_My_Movable_Moda(OldRect:Rect;theWindow:WindowPtr); { Moved this window }
procedure Update_My_Movable_Moda(theWindow:WindowPtr);
procedure Open_My_Movable_Moda;
procedure Close_My_Movable_Moda(theWindow:WindowPtr);
procedure Do_My_Movable_Moda(var theEvent:EventRecord;theWindow:WindowPtr;itemHit:integer);
{ ======================================================= }
{ ======================================================= }
implementation
{ ======================================================= }
{ ======================================================= }
{ Routine: Init_My_Movable_Moda }
{ Purpose: This procedures purpose is to set the window pointer to nil, }
{ this is used to tell the other routines }
procedure Init_My_Movable_Moda;
var
tempRect:Rect; { Temporary rectangle }
DType:integer; { Type of dialog item }
Index:integer; { For looping }
DItem:Handle; { Handle to the dialog item }
CItem, CTempItem:ControlHandle; { Control handle }
sTemp:Str255; { Get text entered, temp holding }
itemHit:integer; { Get selection }
temp:integer; { Get selection, temp holding }
begin
Rec_My_Movable_Moda.theDialog := nil; { Initialize to say that the dialog is not yet active }
Rec_My_Movable_Moda.Enable_OK4 := true; { Button }
Rec_My_Movable_Moda.Enable_Cancel3 := true; { Button }
Rec_My_Movable_Moda.List_List_of_things := nil; { List }
SetRect(Rec_My_Movable_Moda.ListRect_List_of_things,15,10,285,125); { left,top,right,bottom }
U_Init_My_Movable_Moda; { Call the user init routine }
end;
{ ======================================================= }
{ Routine: Moved_My_Movable_Moda }
{ Purpose: We were moved, possibly to another screen and screen depth }
procedure Moved_My_Movable_Moda(OldRect:Rect;theWindow:WindowPtr); { Moved this window }
var
SavePort:WindowPtr; { Place to save the last port }
begin
if (Rec_My_Movable_Moda.theDialog = theWindow) then { Only do if the window is us }
begin
GetPort(SavePort); { Save the current port }
SetPort(theWindow); { Set the port to my window }
U_Moved_My_Movable_Moda(theWindow,OldRect); { Call user routine when we are moved }
SetPort(SavePort); { Restore the old port }
end; { End of IF }
end;
{ ======================================================= }
{ Routine: Update_My_Movable_Moda }
{ Purpose: This procedures purpose is to refresh this window, update it, }
{ when we are uncovered by another window. }
procedure Update_My_Movable_Moda(theWindow:WindowPtr);
var
SavedPort:GrafPtr; { Save the current port so we can restore to it }
tempRect:Rect; { Temporary rectangle variable }
rTempRect:Rect; { Temporary rectangle variable }
DType:integer; { Type of dialog item }
DItem:Handle; { Handle to the dialog item }
CItem:ControlHandle; { Control handle }
Saved_ForeColor:RGBColor; { Place to save colors }
Saved_BackColor:RGBColor; { Place to save colors }
DrawingColor:RGBColor; { Place to make colors }
begin
if ((Rec_My_Movable_Moda.theDialog <> nil) and (theWindow = Rec_My_Movable_Moda.theDialog)) then{ Only do if we are the window to update }
begin
GetPort(SavedPort); { Get the current port }
SetPort(theWindow); { Point to our port for drawing in our window }
if (Has.ColorQD) then { See if color QuickDraw is around }
begin
GetForeColor(Saved_ForeColor); { Save the fore color }
GetBackColor(Saved_BackColor); { Save the back color }
RGBForeColor(Black_ForeColor); { Set the fore color to Black }
RGBBackColor(White_BackColor); { Set the back color to White }
end; { End of IF }
{ This is the default selection, when RETURN is pressed. }
HiliteDefaultButton(theWindow,ResD_OK4);
UpdateTheList(theWindow^.visRgn,Rec_My_Movable_Moda.List_List_of_things,Rec_My_Movable_Moda.ListRect_List_of_things,
12,systemFont,[],true);
TextSize(12);
TextFont(systemFont); { Select the Font that we want }
TextFace([]); { Select the style that we want }
if (Has.ColorQD) then { See if color QuickDraw is around }
begin
RGBForeColor(Saved_ForeColor); { Restore the fore color }
RGBBackColor(Saved_BackColor); { Restore the back color }
end;
U_Update_My_Movable_Moda(theWindow); { Call the user update routine }
DrawDialog(theWindow); { Draw the rest of the controls }
SetPort(SavedPort); { Restore the port that we saved at the start }
end;
end;
{ ======================================================= }
{ Routine: Open_My_Movable_Moda }
{ Purpose: This procedures purpose is to open this window and set all }
{ of the initial conditions, such as default edit text. }
procedure Open_My_Movable_Moda;
var
ThisEditText:TEHandle;
TheDialogPtr:DialogPeek;
tempRect:Rect; { Temporary rectangle variable }
DType:integer; { Type of dialog item }
DItem:Handle; { Handle to the dialog item }
CItem:ControlHandle; { Control handle }
LTemp,LTemp2,theLong:longint; { Get selection, temp holding }
begin
if (Rec_My_Movable_Moda.theDialog = NIL) then
begin
Rec_My_Movable_Moda.theDialog := GetNewDialog(ResD_My_Movable_Moda,NIL,WindowPtr(-1));{ Bring in the dialog resource }
SetPort(Rec_My_Movable_Moda.theDialog); { Prepare to add conditional text }
Doing_MovableModal := true;
{ Button }
SetupNormalControl(Rec_My_Movable_Moda.theDialog,ResD_OK4,Rec_My_Movable_Moda.Enable_OK4,0);
{ Button }
SetupNormalControl(Rec_My_Movable_Moda.theDialog,ResD_Cancel3,Rec_My_Movable_Moda.Enable_Cancel3,0);
{ Make a List }
Make_A_List(Rec_My_Movable_Moda.List_List_of_things,Rec_My_Movable_Moda.ListRect_List_of_things,
Rec_My_Movable_Moda.theDialog,sResD_List_of_things,12,systemFont,[],true);
U_Setup_My_Movable_Moda(Rec_My_Movable_Moda.theDialog);{ Call the user Open procedure }
ShowWindow(Rec_My_Movable_Moda.theDialog); { Open a dialog box }
SelectWindow(Rec_My_Movable_Moda.theDialog); { Lets see it }
end
else
SelectWindow(Rec_My_Movable_Moda.theDialog); { Lets see it }
end;
{ ======================================================= }
{ Routine: Close_My_Movable_Moda }
{ Purpose: This procedures purpose is to close this window and clear }
{ the window pointer variable }
procedure Close_My_Movable_Moda(theWindow:WindowPtr);
var
tempRect:Rect; { Temporary rectangle }
DType:integer; { Type of dialog item }
DItem:Handle; { Handle to the dialog item }
begin
if ((Rec_My_Movable_Moda.theDialog <> NIL) and (theWindow = Rec_My_Movable_Moda.theDialog)) then{ Only close if it is us and we were open }
begin
U_Close_My_Movable_Moda(theWindow); { Call the user close routine }
Doing_MovableModal := false;
DisposDialog(theWindow); { Close on the screen and Flush the dialog out of memory }
Rec_My_Movable_Moda.theDialog := nil; { Make sure our other routines know that we are closed }
end;
end;
{ ======================================================= }
{ Routine: Do_My_Movable_Moda }
{ Purpose: This procedures purpose is to handle all actions, such as buttons being pressed. }
{ This is the real meat of this unit and is where the code is for acting upon the users actions. }
procedure Do_My_Movable_Moda(var theEvent:EventRecord;theWindow:WindowPtr;itemHit:integer);
var
Index:integer; { For looping }
myPt:Point; { For the local mouse position }
DType:integer; { Type of dialog item }
DItem:Handle; { Handle to the dialog item }
tempRect:Rect; { Temporary rectangle }
CItem:ControlHandle; { Control handle }
temp:integer; { temp integer }
code:integer; { temp integer }
theSelection:integer; { For Palettes }
DoubleClick:Boolean; { For sensing double clicks in a list }
begin
Rec_My_Movable_Moda.ExitDialog := false; { Do not close the dialog yet }
if ((theEvent.what = mouseDown) and (Rec_My_Movable_Moda.theDialog <> nil)) then
begin
SetPort(Rec_My_Movable_Moda.theDialog); { Set the port to our dialog }
myPt := theEvent.where; { Get the position where the mouse was pressed }
GlobalToLocal(myPt); { Change from global to local location }
if (PtInRect(myPt,Rec_My_Movable_Moda.ListRect_List_of_things)) then
ClickInTheList(myPt,theEvent.modifiers,Rec_My_Movable_Moda.List_List_of_things,12,systemFont,[],true);
end;
if ((Rec_My_Movable_Moda.theDialog <> nil) and (Rec_My_Movable_Moda.theDialog = theWindow)) then
begin
CheckKeysInDialog(theWindow,DoubleClick,theEvent,itemHit);
myPt := theEvent.where; { Get the position where the mouse was pressed }
GlobalToLocal(myPt); { Change from global to local location }
U_Hit_My_Movable_Moda(theWindow,itemHit,Rec_My_Movable_Moda.ExitDialog,theEvent);{ Give the user the itemhit }
if (itemHit > 0) then { Skip if user set to zero }
begin
GetDItem(theWindow,itemHit,DType,DItem,tempRect);{ Get which item was pressed }
CItem := ControlHandle(DItem); { Change the pointer for getting to the control }
end;
{ Handle it real time }
if (itemHit = ResD_OK4) then { Handle the Button being pressed }
begin
Add_UserEvent(UserEvent_Close_Window,ResD_My_Movable_Moda,0,0,nil); { Close this modeless dialog }
Rec_My_Movable_Moda.ExitDialog := true; { Close this dialog, exit }
end;
if (itemHit = ResD_Cancel3) then { Handle the Button being pressed }
begin
Add_UserEvent(UserEvent_Close_Window,ResD_My_Movable_Moda,0,0,nil); { Close this modeless dialog }
Rec_My_Movable_Moda.ExitDialog := true; { Close this dialog, exit }
end;
end;
if (Rec_My_Movable_Moda.ExitDialog) then { Do the close of the dialog }
begin
Close_My_Movable_Moda(Rec_My_Movable_Moda.theDialog);
Rec_My_Movable_Moda.theDialog := nil; { Clear it for future checks }
end;
end;
{ ======================================================= }
{ ======================================================= }
end.